package com.icow.wms.basic.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.icow.common.annotation.Log;
import com.icow.common.core.controller.BaseController;
import com.icow.common.core.domain.AjaxResult;
import com.icow.common.enums.BusinessType;
import com.icow.wms.basic.domain.OrderType;
import com.icow.wms.basic.service.IOrderTypeService;
import com.icow.common.utils.poi.ExcelUtil;
import com.icow.common.core.page.TableDataInfo;

/**
 * orderTypeController
 *
 * @author bcs
 * @date 2024-08-21
 */
@RestController
@RequestMapping("/wcs/orderType")
public class OrderTypeController extends BaseController
{
    @Autowired
    private IOrderTypeService orderTypeService;

/**
 * 查询orderType列表
 */
@PreAuthorize("@ss.hasPermi('wcs:orderType:list')")
@GetMapping("/list")
        public TableDataInfo list(OrderType orderType)
    {
        startPage();
        List<OrderType> list = orderTypeService.selectOrderTypeList(orderType);
        return getDataTable(list);
    }
    
    /**
     * 导出orderType列表
     */
    @PreAuthorize("@ss.hasPermi('wcs:orderType:export')")
    @Log(title = "orderType", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderType orderType)
    {
        List<OrderType> list = orderTypeService.selectOrderTypeList(orderType);
        ExcelUtil<OrderType> util = new ExcelUtil<OrderType>(OrderType.class);
        return util.exportExcel(list, "orderType");
    }

    /**
     * 获取orderType详细信息
     */
    @PreAuthorize("@ss.hasPermi('wcs:orderType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderTypeService.selectOrderTypeById(id));
    }

    /**
     * 新增orderType
     */
    @PreAuthorize("@ss.hasPermi('wcs:orderType:add')")
    @Log(title = "orderType", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderType orderType)
    {
        return toAjax(orderTypeService.insertOrderType(orderType));
    }

    /**
     * 修改orderType
     */
    @PreAuthorize("@ss.hasPermi('wcs:orderType:edit')")
    @Log(title = "orderType", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderType orderType)
    {
        return toAjax(orderTypeService.updateOrderType(orderType));
    }

    /**
     * 删除orderType
     */
    @PreAuthorize("@ss.hasPermi('wcs:orderType:remove')")
    @Log(title = "orderType", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderTypeService.deleteOrderTypeByIds(ids));
    }
}